package com.hamster.crmpre.web;

import com.hamster.crmpre.pojo.CustomerRecord;
import com.hamster.crmpre.service.BranchEnterCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 事业部为分公司录入客户 的Controller
 * @author Tarry
 * @create 2020/1/7 20:47
 */
@RestController
@RequestMapping("branchEnterCustomer")
public class BranchEnterCustomerController {
    @Autowired
    private BranchEnterCustomerService branchEnterCustomerService;


    /**
     * 为分公司录入的
     * @param companyId  分公司id【为哪个分公司录入】
     * @param customerRecord 表单页面的内容
     * @return
     */
    @PostMapping("insert")
    public ResponseEntity<Void> insert(@RequestParam String companyId,@RequestBody CustomerRecord customerRecord ){
        branchEnterCustomerService.notify(companyId,customerRecord);

        return ResponseEntity.ok().build();
    }

    /**
     * 为分公司，补交尾款
     * @param id    分公司id
     * @param money 补交金额
     * @return
     */
    @GetMapping("payTheBalance")
    public ResponseEntity<Void> payTheBalance(@RequestParam String id,@RequestParam Double money){

        branchEnterCustomerService.payTheBalance(id,money);

        return ResponseEntity.ok().build();
    }


}
